//
//  DepoistInfoDateCell.swift
//  d11
//
//  Created by peale on 2018/10/21.
//  Copyright © 2018年 Tech_001. All rights reserved.
//

import UIKit

class DepoistInfoDateCell: UITableViewCell {

    var bgImgView : UIImageView?
    var iconImgView : UIImageView?
    var titleLabel : UILabel?
    var yearLabel : UILabel?
    var yearImgView :UILabel?
    var monthLabel : UILabel?
    var monthImgView :UILabel?
    var dayLabel : UILabel?
    var dayImgView :UILabel?
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    func setUpUI() -> Void {
        self.backgroundColor  = UIColor.clear
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        // self.contentView!.backgroundColor  = UIColor.clear
        self.bgImgView = UIImageView.init()
        self.bgImgView?.image = imageNamed("icon_my_cell_item")?.resizableImage(withCapInsets: UIEdgeInsets(top: 5, left: 30, bottom: 5, right: 30),
                                                                                resizingMode: .stretch) //左右15像素的部分不变，中间部分来拉伸
        self.contentView.addSubview(bgImgView!);
        self.bgImgView?.snp.makeConstraints{(make) in
            make.width.equalToSuperview()
            make.height.equalTo(60)
            make.centerX.equalTo(self.contentView)
        };
        
        self.iconImgView = UIImageView.init()
        self.iconImgView?.image = imageNamed("icon_depoist_input_info_date")
        self.bgImgView?.addSubview(self.iconImgView!)
        self.iconImgView?.snp.makeConstraints{(make) in
            make.left.equalToSuperview().offset(12)
            make.width.equalTo(20)
            make.height.equalTo(20)
            make.centerY.equalTo(self.bgImgView!)
        }
        self.titleLabel = UILabel.init()
        self.titleLabel?.text = "存款日期"
        self.titleLabel?.textColor = HexRGBAlpha(0x333333, 1)
        self.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        self.titleLabel?.textAlignment = NSTextAlignment.left
        self.bgImgView?.addSubview(self.titleLabel!)
        
        self.titleLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.iconImgView?.snp.right)!).offset(12)
            make.width.equalTo(70)
            make.height.equalTo(51)
            make.centerY.equalToSuperview()
        }
        
        self.yearLabel = UILabel.init()
        self.yearLabel?.text = "2018"
        self.yearLabel?.textColor = HexRGBAlpha(0x666666, 1)
        self.yearLabel?.font = UIFont.systemFont(ofSize: 14)
        self.yearLabel?.textAlignment = NSTextAlignment.right
        self.bgImgView?.addSubview(self.yearLabel!)
        
        self.yearLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.titleLabel?.snp.right)!).offset(12)
            make.width.equalTo(35)
            make.centerY.equalToSuperview()
            make.height.equalTo(51)
        }
        
        self.yearImgView = UILabel.init()
     //   self.yearImgView?.image = imageNamed("icon_depoist_input_info_arrow")
     //   self.yearImgView?.isHidden = true
        self.yearImgView?.textColor = HexRGBAlpha(0x666666, 1)
        self.yearImgView?.font = UIFont.systemFont(ofSize: 14)
        self.yearImgView?.textAlignment = NSTextAlignment.left
        self.yearImgView?.text = "年"
        self.bgImgView?.addSubview(self.yearImgView!)
        self.yearImgView?.snp.makeConstraints{(make) in
            make.left.equalTo((self.yearLabel?.snp.right)!).offset(3)
            make.width.equalTo(20)
            make.height.equalTo(51)
            make.centerY.equalTo(self.bgImgView!)
        }
        self.monthLabel = UILabel.init()
        self.monthLabel?.text = "06"
        self.monthLabel?.textColor = HexRGBAlpha(0x666666, 1)
        self.monthLabel?.font = UIFont.systemFont(ofSize: 14)
        self.monthLabel?.textAlignment = NSTextAlignment.right
        self.bgImgView?.addSubview(self.monthLabel!)
        
        self.monthLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.yearImgView?.snp.right)!)
            make.width.equalTo(25)
            make.centerY.equalToSuperview()
            make.height.equalTo(51)
        }
        
        self.monthImgView = UILabel.init()
      //  self.monthImgView?.image = imageNamed("icon_depoist_input_info_arrow")
        self.monthImgView?.textColor = HexRGBAlpha(0x666666, 1)
        self.monthImgView?.font = UIFont.systemFont(ofSize: 14)
        self.monthImgView?.textAlignment = NSTextAlignment.left
        self.monthImgView?.text = "月"
        self.bgImgView?.addSubview(self.monthImgView!)
        self.monthImgView?.snp.makeConstraints{(make) in
            make.left.equalTo((self.monthLabel?.snp.right)!).offset(3)
            make.width.equalTo(20)
            make.height.equalTo(51)
            make.centerY.equalTo(self.bgImgView!)
        }
        
        
        self.dayLabel = UILabel.init()
        self.dayLabel?.text = "22"
        self.dayLabel?.textColor = HexRGBAlpha(0x666666, 1)
        self.dayLabel?.font = UIFont.systemFont(ofSize: 14)
        self.dayLabel?.textAlignment = NSTextAlignment.right
        self.bgImgView?.addSubview(self.dayLabel!)
        
        self.dayLabel?.snp.makeConstraints{(make) in
            make.left.equalTo((self.monthImgView?.snp.right)!)
            make.width.equalTo(25)
            make.centerY.equalToSuperview()
            make.height.equalTo(51)
        }
        
        self.dayImgView = UILabel.init()
       // self.dayImgView?.image = imageNamed("icon_depoist_input_info_arrow")
        self.dayImgView?.textColor = HexRGBAlpha(0x666666, 1)
        self.dayImgView?.font = UIFont.systemFont(ofSize: 14)
        self.dayImgView?.textAlignment = NSTextAlignment.left
        self.dayImgView?.text = "日"
        self.bgImgView?.addSubview(self.dayImgView!)
        self.dayImgView?.snp.makeConstraints{(make) in
            make.left.equalTo((self.dayLabel?.snp.right)!).offset(3)
            make.width.equalTo(20)
            make.height.equalTo(51)
            make.centerY.equalTo(self.bgImgView!)
        }
        
    }
    
    func setData(year:String?,moth:String?,day:String?,row:Int)->Void{
        self.yearLabel?.text = year
        self.monthLabel?.text = moth
        self.dayLabel?.text = day
    }
}
